﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Json;

namespace exsportance.Silverlight.Common.Utils
{
    public static class JsonUtils
    {
        /// <summary>
        /// Get the value as string
        /// </summary>
        /// <param name="value"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string AsString(this JsonValue value, string key)
        {
            return (string)value[key];
        }

        /// <summary>
        /// Get the value as boolean
        /// </summary>
        /// <param name="value"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool AsBool(this JsonValue value, string key)
        {
            return (bool)value[key];
        }

        /// <summary>
        /// Get the valus as integer
        /// </summary>
        /// <param name="value"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static int AsInt(this JsonValue value, string key)
        {
            return (int)value[key];
        }
    }
}
